import { get } from '@/utils/http'
import type { BasicPagingListResult, BasicPagingListParams } from '@/apis/basicModel'
import type {
  GetListVisibleModelParams,
  GetListVisibleModelResult,
  GetVisibleModelDetailResult,
  GetModelLifecycleEmissionResult,
  GetModelFLowEmissionResult,
  GetModelPartsEmissionResult,
  GetComparisonListResult
} from './model/pcfFormModel'

enum Api {
  // 分页查询可视化模型
  GET_LIST_VISIBLE_MODEL = '/footprint/modelInfo/pageVisibleModel',
  // 获取最近核算成功的可视化模型
  GET_LAST_VISIBLE_MODEL = '/footprint/modelInfo/getLastVisibleModel',
  // 查询可视化模型详情信息
  GET_VISIBLE_MODEL_DETAIL = '/footprint/modelInfo/modelVisibleDetail',
  /**
   * 分布分析
   */
  // 模型生命阶段排放分布
  GET_LIFECYCLE_EMISSION = '/footprint/visible/distribution/modelStageEmission',
  // 模型输入输出流排放
  GET_FLOW_EMISSION = '/footprint/visible/distribution/modelFlowEmission',
  // 模型零部件排放分布
  GET_PARTS_EMISSION = '/footprint/visible/distribution/modelItemEmission',
  /**
   * 对比分析
   */
  // 模型排放对比
  GET_COMPARISON_LIST = '/footprint/visible/comparison/modelEmission'
}

// 分页查询可视化模型
export const getListVisibleModel = (
  params: GetListVisibleModelParams & BasicPagingListParams
): Promise<BasicPagingListResult<GetListVisibleModelResult>> =>
  get(Api.GET_LIST_VISIBLE_MODEL, params)

// 获取最近核算成功的可视化模型
export const getLastVisibleModel = (): Promise<string> => get(Api.GET_LAST_VISIBLE_MODEL)

// 查询可视化模型详情信息
export const getVisibleModelDetail = (modelNo: string): Promise<GetVisibleModelDetailResult> =>
  get(Api.GET_VISIBLE_MODEL_DETAIL, { modelNo })

/**
 * 分布分析
 */
// 模型生命阶段排放分布
export const getModelLifecycleEmission = (
  modelNo: string
): Promise<GetModelLifecycleEmissionResult[]> => get(Api.GET_LIFECYCLE_EMISSION, { modelNo })

// 模型输入输出流排放
export const getModelFLowEmission = (modelNo: string): Promise<GetModelFLowEmissionResult> =>
  get(Api.GET_FLOW_EMISSION, { modelNo })

// 模型零部件排放分布
export const getModelPartsEmission = (modelNo: string): Promise<GetModelPartsEmissionResult> =>
  get(Api.GET_PARTS_EMISSION, { modelNo })

// 模型排放对比
export const getComparisonList = (
  leftModelNo: string,
  rightModelNo?: string
): Promise<GetComparisonListResult> => get(Api.GET_COMPARISON_LIST, { leftModelNo, rightModelNo })
